package cn.mn.ac.rocketmq.handler;

import com.aliyun.openservices.ons.api.OnExceptionContext;
import com.aliyun.openservices.ons.api.SendCallback;
import com.aliyun.openservices.ons.api.SendResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author 何福临
 * @date 2022-08-29 20:33
 */
public class SendCallbackHandler implements SendCallback {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void onSuccess(SendResult sendResult) {
        logger.info("SendCallback topic:{}, messageId:{}, 发送成功!", sendResult.getTopic(), sendResult.getMessageId());
    }

    @Override
    public void onException(OnExceptionContext context) {
        logger.error("SendCallback topic:{}, messageId:{}, ex:{}, 发送失败!", context.getTopic(), context.getMessageId(), context.getException());
    }

}
